package com;

import java.io.UnsupportedEncodingException;

import com.google.android.maps.GeoPoint;

public class PassByUtiles {
	public static GeoPoint decodeGeoPt(String p)
	{
		float lat = Float.parseFloat(p.split(",")[0]);
		float lon = Float.parseFloat(p.split(",")[1]);
		return new GeoPoint((int) (lat * 1000000), (int)(lon * 1000000));
	}
	
	public static String encodeGeoPt(GeoPoint p)
	{
		int lat = p.getLatitudeE6();
		double la = lat/1E6;
		int lon = p.getLongitudeE6();
		double lo = lon/1E6;
		return Double.toString(la)+","+Double.toString(lo);
	}
	
	public static String toUtf8(String s)
	{
		String result = s;
		try {
			byte[] b = s.getBytes("iso-8859-1");
			result = new String(b, "UTF-8");
//			result = new String(b, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return result;
	}
}
